package java复习202407;

import org.junit.jupiter.api.Test;

public class c12_类加载器验证 {

    @Test
    public void 应用类加载器(){
        ClassLoader appClassLoader = c12_类加载器验证.class.getClassLoader();
        ClassLoader extClassLoader = appClassLoader.getParent();
        ClassLoader bootstrap = extClassLoader.getParent();
        System.out.println(appClassLoader);
        System.out.println(extClassLoader);
        System.out.println(bootstrap);

        // 使用线程的方法设置类加载器加载类
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println("systemClassLoader:"+systemClassLoader);
        Thread thread = Thread.currentThread();
        thread.setContextClassLoader(systemClassLoader);

    }

    @Test
    public void 测试自定义String类是被加载(){
        String s = new String();
        System.out.println(s);
    }
}
